import 'package:easy_chat_app/commons/GlobalStatus.dart';
import 'package:easy_chat_app/commons/model/AppUserDetail.dart';
import 'package:easy_chat_app/commons/utils/RouteUtils.dart';
import 'package:easy_chat_app/commons/widget/UserHeadPortrait.dart';
import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
import 'package:provider/provider.dart';

class MobilePersonalCenterPageDataChangeNotifier extends ChangeNotifier {}

class MobilePersonalCenterPage extends StatelessWidget {
  final Logger logger = Logger();

  MobilePersonalCenterPage({super.key});

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (context) {
          return MobilePersonalCenterPageDataChangeNotifier();
        })
      ],
      child: Consumer<AppUserDetailChangeNotifier>(
          builder: (context, appUserDetailChangeNotifier, child) {
        AppUserDetail userDetail =
            appUserDetailChangeNotifier.getAppUserDetail();
        return Container(
          color: const Color.fromRGBO(237, 237, 237, 1),
          child: Column(
            children: [
              GestureDetector(
                onTap: () async {
                  await RouteUtils.route2MobileUserInfoPage();
                },
                child: Container(
                  color: Colors.white,
                  height: 145,
                  padding: const EdgeInsets.only(top: 50, bottom: 30),
                  child: Column(
                    children: [
                      Container(
                        padding: const EdgeInsets.only(left: 30),
                        child: Row(
                          children: [
                            UserHeadPortrait.network(
                                size: 65,
                                userCode: userDetail.code!,
                                userHeadPortrait: userDetail.headPortrait!,
                                userHeadPortraitStoreType:
                                    userDetail.headPortraitStoreType!),
                            const SizedBox(
                              width: 20,
                              height: 65,
                            ),
                            Expanded(
                                child: Container(
                              alignment: Alignment.bottomLeft,
                              child: Column(
                                children: [
                                  Container(
                                    alignment: Alignment.centerLeft,
                                    child: Text(
                                      userDetail.nickname!,
                                      style: const TextStyle(fontSize: 22),
                                    ),
                                  ),
                                  Container(
                                    alignment: Alignment.centerLeft,
                                    child: Text(
                                      "EC号: ${userDetail.code!}",
                                      style: const TextStyle(
                                          fontSize: 18,
                                          color:
                                              Color.fromRGBO(107, 107, 107, 1)),
                                    ),
                                  ),
                                ],
                              ),
                            )),
                            Container(
                              height: 65,
                              alignment: Alignment.bottomRight,
                              child: const Row(
                                children: [
                                  Icon(Icons.qr_code),
                                  Icon(Icons.chevron_right)
                                ],
                              ),
                            ),
                            const SizedBox(
                              width: 18,
                            )
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
              ),
              Container(
                height: 10,
              ),
              GestureDetector(
                onTap: () {
                  RouteUtils.route2MobileUserSettingPage();
                },
                child: Container(
                  height: 55,
                  padding: const EdgeInsets.only(left: 30),
                  color: Colors.white,
                  child: const Row(
                    children: [
                      Icon(
                        Icons.settings,
                        color: Colors.blue,
                        size: 22,
                      ),
                      SizedBox(
                        width: 10,
                      ),
                      Text(
                        "设置",
                        style: TextStyle(fontSize: 16),
                      ),
                      Spacer(),
                      Icon(Icons.keyboard_arrow_right),
                      SizedBox(
                        width: 18,
                      )
                    ],
                  ),
                ),
              )
            ],
          ),
        );
      }),
    );
  }
}
